package be.kiojeux.dwr;

import java.util.List;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

import be.kiojeux.bean.AttendanceBean;
import be.kiojeux.bean.BarBean;
import be.kiojeux.bean.GameBean;
import be.kiojeux.bean.GameTypeBean;
import be.kiojeux.bean.HomeBean;
import be.kiojeux.bean.SubscriptionBean;
import be.kiojeux.bean.UserBean;
import be.kiojeux.servlets.start.ListsGenerator;

public class SecretariatDWR {//implements Runnable {

	boolean flagListUB = true;

	/**
	 * Constructor - Creates a thread pool that runs every 1 second.
	
    public SecretariatDWR()
    {
        ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1, new DaemonThreadFactory());
        executor.scheduleAtFixedRate(this, 1, 1, TimeUnit.SECONDS);
    }
    */
    /* (non-Javadoc)
     * @see java.lang.Runnable#run()
     
    @Override
    public void run()
    {
    	if(ListsGenerator.flagListUB != flagListUB) {
	    	Browser.withCurrentPage(new Runnable()
	        {
	            public void run()
	            {
	                ScriptSessions.addFunctionCall("myResult()", getNextSession());
	            }
	        });
    	}
    }
	*/
    
	// --------------------------------- getters pour le refresh des pages (dwr) ----------------------------------
	
	public List<UserBean> getListUB(boolean flag) {
		
		if(ListsGenerator.flagListUB != flag) {
			return ListsGenerator.listUB;   
		}
    	else {
    		return null;
    	}
	}    
   
    public static List<String> getListEmail(boolean flag) {
    	
    	if(ListsGenerator.flagListEmail != flag) {
        	
    		return ListsGenerator.listEmail;
    	}
    	else {
    		return null;
    	}
    }
    
    public static List<UserBean> getListUBDelete(boolean flag) {
    	
    	if(ListsGenerator.flagListUBDelete != flag) {
        	
    		return ListsGenerator.listUBDelete;
    	}
    	else {
    		return null;
    	}
    }
    
    public static List<SubscriptionBean> getListUserSubscription(boolean flag) {
    	
    	if(ListsGenerator.flagListUserSubscription != flag) {
        	
    		return ListsGenerator.listUserSubscription;
    	}
    	else {
    		return null;
    	}
    }
    
    public static List<BarBean> getListBB(boolean flag) {
    	
    	if(ListsGenerator.flagListBB != flag) {
        	
    		return ListsGenerator.listBB;
    	}
    	else {
    		return null;
    	}
    }
    
    public static List<UserBean> getListUBDrink(boolean flag) {
    	
    	if(ListsGenerator.flagListUBDrink != flag) {
        	
    		return ListsGenerator.listUBDrink;
    	}
    	else {
    		return null;
    	}
    }
    
    public static List<GameBean> getListGB(boolean flag) {
    	
    	if(ListsGenerator.flagListGB != flag) {
        	
    		return ListsGenerator.listGB;
    	}
    	else {
    		return null;
    	}
    }
    
    public static List<GameTypeBean> getListGTB(boolean flag) {
    	
    	if(ListsGenerator.flagListGTB != flag) {
        	    		
    		return ListsGenerator.listGTB;
    	}
    	else {
    		return null;
    	}
    }
    
    public static List<HomeBean> getListHB(boolean flag) {
    	
    	if(ListsGenerator.flagListHB != flag) {
        	
    		return ListsGenerator.listHB;
    	}
    	else {
    		return null;
    	}
    }
      
    public static AttendanceBean getNextSession(boolean flag) {
    	
    	if(ListsGenerator.flagNextSession != flag) {
    		return ListsGenerator.nextSession;    	
    	}
    	else {
    		return null;
    	}
    }
}
